import { Type } from 'class-transformer'
import { Allow, ArrayNotEmpty, IsDate, IsNotEmpty, IsOptional, MaxLength } from 'class-validator'
import i18n, { i18nMessage } from '@/i18n'
import { ApiProperty } from '@nestjs/swagger'

export class MetaPlatformGetHistoryChartDataParams {
  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.066365-0') })
  @IsOptional()
  dataFillingStrategy?: string

  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.066365-1') })
  @IsNotEmpty()
  queryGranularity: string

  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.066365-2') })
  @Allow()
  timeRange: number[]

  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.066365-3') })
  @IsDate()
  @Type(() => Date)
  beginTime: number

  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.066365-4') })
  @IsDate()
  @Type(() => Date)
  endTime: number

  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.066365-5') })
  @ArrayNotEmpty()
  dataSourcePaths: string[]
}

export class MetaPlatformGetHistoryChartDataDto {
  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.637479-0') })
  @IsNotEmpty()
  @MaxLength(64, { message: i18nMessage() })
  platform: string

  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.637479-1') })
  @MaxLength(64, { message: i18nMessage() })
  @IsOptional()
  project?: string

  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.637479-2') })
  @IsNotEmpty()
  token: string

  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.637479-3') })
  @Allow()
  dataHash?: string

  @ApiProperty({ description: i18n.t('dto.meta-platform-get-history-chart-data.637479-4') })
  @IsNotEmpty()
  params: MetaPlatformGetHistoryChartDataParams
}
